<div class="messages">
    {% if messages %}

        {% for message in messages %}
            <div class="message {{message.tags}}Message" id="message-{{forloop.counter}}">
                <span class="message-img"></span>
                {{message}}
            </div>
            <script type="text/javascript">
                new Message($("message-{{forloop.counter}}"))
            </script>
        {% endfor %}
    {% endif %}
    {% if unread_pms %}
        <div class="message infoMessage pmMessage" id="pm-msg">
            <script type="text/javascript">
                new Message($("pm-msg"))
            </script>
            <span class="message-img"></span>
            
            You have {{unread_pms}} unread private message{{unread_pms|pluralize}}.
            <br />
            The most recent is 
            '<a href="{% url pms:read_pm latest_pm.pk %}">{{latest_pm}}</a>'
            from <a href="{% url account:view_profile latest_pm.from_user.pk %}">{{latest_pm.from_user}}</a>.
            <a href="{% url pms:index %}">View all of your private messages</a>
        </div>
    {% endif %}
</div>